import React from "react";
import Child from "./Child";
import { Button } from "antd";

export default class Life extends React.Component{
    //构造函数
    constructor(props) {
        super(props);
        this.state ={
            count: 0
        }
    }
    //es6 this
    handleAdd=()=>{
        this.setState({
            count: this.state.count + 1
        })
    }
    //bind 传递this
    handleClick(){
        this.setState({
            count: this.state.count + 1
        })
    }
    //渲染函数
    render() {
            return <div style={{padding: 50}}>
                        <p>React Antd修改自定义主题颜色</p>
                        <Button type="primary"  onClick={this.handleAdd}>primary</Button>
                        <Button onClick={this.handleClick.bind(this)}>默认</Button>
                        <p>{this.state.count}</p>
                        <Child name="Jack"></Child>
                    </div>
    }
}